home *** CD-ROM | disk | FTP | other *** search
/ Aminet 3 / Aminet 3 - July 1994.iso / Aminet / demo / mag / sta_hdl2.dms / sta_hdl2.adf / HDL2Data / DotObjects.stc / DotObjects
Encoding:
Text File  |  1992-12-21  |  2.2 KB  |  80 lines

  1. ±b2  DOT-OBJECTS - AN×
  2.  
  3.  
  4. ±b2     APPROACH!!
  5.  
  6.  
  7. ±22By Fizban/Compact
  8.  
  9. ±41I  guess you all have seen traditional
  10. vector-dot  objects  like "balls" etc.
  11. But  how are the data for this kind of
  12. object  made?   Are  they written down
  13. manually  like  in  the avarage filled
  14. vector?   Of  course  not!   Who would
  15. have   the   patience  to  write  down
  16. XYZ-data for a thousand+ dots?  Here's
  17. where  a  couple  of  formulas come in
  18. handy......   Lets  imagine  a sphere.
  19. It  will, just like a globe, have both
  20. a   longitude  and  a  latitude.   The
  21. longitude is the north-south direction
  22. of  the  sphere, while the latitude is
  23. the  east-west  direction.  Both these
  24. numbers  are  from  0  to 360 degrees.
  25. This   means   that   we'll  need  two
  26. numbers,   written   in   degrees,  to
  27. calculate  the  X, Y and Z position of
  28. the point.
  29.  
  30. ±23And here's the formula:
  31.  
  32. ±41D1 = Longitude   (Degree 1)
  33. D2 = Latitude    (Degree 2)
  34.  
  35. X  = Sin(D1)*Cos(D2)
  36. Y  = Sin(D1)*Sin(D2)
  37. Z  = Cos(D1)
  38.  
  39.  
  40.  
  41. ±22Let's have an example:
  42. ±41Lea     Points,a0    ;Points-table
  43. Lea     Sinus,a1     ;Sinus-table
  44. Lea     Sinus+180,a2 ;Cosinus-table
  45. Move.l  #10,d0       ;Longtitude
  46. Move.l  #56,d1       ;Latitude
  47. Add     d0,d0        ;D0=Word pointer
  48. Add     d1,d1        ;D1-----""------
  49. Move.w  (a1,d0.w),d2 ;Sin(D1)
  50. Muls    (a2,d1.w),d2 ;Sin(D1)*Cos(D2)
  51. Swap    d2           ;Scale down 
  52. Move.w  d2,(a0)+     ;Store X
  53. Move.w  (a1,d0.w),d2 ;Sin(D1)
  54. Muls    (a1,d1.w),d2 ;Sin(D1)*Sin(D2)
  55. Swap    d2           ;Scale down
  56. Move.w  d2,(a0)+     ;Store Y
  57. Move.w  (a2,d0.w),d2 ;Cos(D1)
  58. Asr     #8,d2        ;Scale down
  59. Move.w  d2,(a0)+     ;Store Z
  60. Rts
  61. ±41Now  you can start making a loop which
  62. calculates,  let's say 1000 dots.  For
  63. this  purpose  you  can use randomized
  64. numbers  for  Long.   and Lat.  or you
  65. can  add  with  a  constant  for  each
  66. point.   When  the dots are calculated
  67. you  will  of  course  have  to rotate
  68. them.   For  this  you use an ordinary
  69. rotate  routine.   I  will not explain
  70. the rotation in this article.
  71.  
  72. This  example  was  for  a sphere, but
  73. with  a  little fantasy (and luck) you
  74. can  create some weird objects.  Let's
  75. say  you instead of X= sin(D1)*cos(D2)
  76. use  X=  Sin(D1+90)*Cos(D2+45)........
  77. The possibilities are almost infinite.
  78. Once  I  managed to create a sort of a
  79. mug(?).......  So start experimenting!
  80. ç